package com.cssw.fyzb.busi.api.user;


import com.cssw.fyzb.busi.service.user.UserService;
import com.cssw.fyzb.core.model.dodb.User;
import com.cssw.fyzb.core.model.mos.UserMo;
import com.cssw.fyzb.core.model.vo.user.UserIdVo;
import com.ydn.appserver.Action;
import com.ydn.appserver.Request;
import com.ydn.appserver.Response;
import com.ydn.appserver.annotations.Function;
import com.ydn.appserver.annotations.Parameter;
import com.ydn.appserver.annotations.Type;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 获取用户信息
 *
 * @author YangYiQun
 */
@Function(description = "检查用户手机号是否存在用户", parameters = {
        @Parameter(name = "userId", type = Type.Integer, description = "用户标识", required = true),
        @Parameter(name = "status", type = Type.String, description = "状态", required = true)
})
@Component
public class UpdateUserStatus implements Action {

    @Autowired
    private UserService userService;

    private static final Logger logger = LoggerFactory.getLogger(UpdateUserStatus.class);

    @Override
    public Response execute(Request request) throws Exception {
        String status = request.getString("status");
        Long userId = request.getLong("userId");
        try {

            userService.updateStatus(userId, status);

            return Response.success();
        } catch (Exception e) {
            logger.error("", e);
            return Response.fail("用户信息获取失败");
        }
    }
}
